import request from '@/utils/request'
import qs from 'qs'

const permApi = {
  /**
   * 查询分页
   * @param {*} params
   */
  listPage(params) {
    return request({ url: '/perm/page', method: 'get', params })
  },
  /**
   * 查询全部
   * @param {*} params
   */
  listAll(params) {
    return request({ url: '/perm/list', method: 'get', params })
  },
  /**
   * 查询权限树
   * fetchTreeList
   * @param {*} params
   */
  permTree(params) {
    return request({ url: '/perm/tree', method: 'get', params })
  },
  /**
   * 新增权限
   * @param {*} data
   */
  add(data) {
    return request({ url: '/perm', method: 'post', data })
  },
  /**
   * 编辑权限
   * @param {*} data
   */
  edit(data) {
    return request({ url: '/perm', method: 'put', data })
  },
  /**
   * 批量删除
   * @param {*} params
   */
  deleteByIds(params) {
    return request({
      url: '/perm',
      method: 'delete',
      params,
      paramsSerializer: params => {
        return qs.stringify(params, { indices: false })
      }
    })
  }
}

export default permApi
